define(function(require, exports, module){
	require("resource/js/easyui/easyloader.js");
	require("resource/js/easyui/themes/icon.css");
	var A = require('resource/js/component/ajax.js');
	var parseRecurrence = require('resource/js/component/parseRecurrence.js');
	var urlTool = require('resource/js/component/urlTool.js');
	require("resource/js/component/ztreeStyle.css");
	require("resource/js/component/tree.js");
	var setting = { view: { showLine: false, showIcon: false, selectedMulti: false, dblClickExpand: false, addDiyDom: addDiyDom,
		fontCss: getFontCss
	}, data: { simpleData: { enable: true } }, callback: { onClick: onClick } };
	var Obj = window.loadI18n('base/user');
	var menuMap={};
	var maxDate="";
	function addDiyDom(treeId, treeNode) {
		var spaceWidth = 5;
		var switchObj = $("#" + treeNode.tId + "_switch"),
		icoObj = $("#" + treeNode.tId + "_ico");
		switchObj.remove();
		icoObj.after(switchObj);
		icoObj.parent().css("display","table");
		$("#" + treeNode.tId + "_span").css({"display":"table-cell"});
//		if (treeNode.level == 0) {
//			$("#" + treeNode.tId + "_span").css("padding","3px 0px 0px 27px");
//			switchObj.remove();
//			icoObj.css("width","20px");
//			icoObj.css("height","auto");
//			icoObj.html("<img style='width: 20px;border:none;' src='"+BASEPATH+treeNode.img+"'/>");
//		}
		if (treeNode.level == 1) {
			if(treeNode.pId!="001"){
				if(treeNode.tId=="navigat_2"){
					if(treeNode.orderBy==1){
						$("#"+treeNode.tId+"_span").click();
						tabClick_=false;
					}
				}
			}
			$("#" + treeNode.tId + "_span").css("padding","3px 0px 0px 50px");
			switchObj.remove();
			icoObj.css("width","20px");
			icoObj.css("height","auto");
			icoObj.html("<img style='width: 20px;border:none;' src='"+BASEPATH+treeNode.img+"'/>");
		}
	}
	function getFontCss(treeId, treeNode) {
		return (!!treeNode.highlight) ? {color:"#A60000", "font-weight":"bold","overflow":"hidden",
			"text-overflow":"ellipsis"} : {"font-weight":"normal"};
	}
	
	var index = 1;
	function onClick(event, treeId, treeNode, clickFlag) {
		var zTree = $.fn.zTree.getZTreeObj("navigat");
		if(treeNode.open){
			$(event.target).closest("a").removeClass("expand").find("img").attr("src",BASEPATH+treeNode.img);
			if('menu'==treeNode.funType){
				index++;
				var child =treeNode.children;
				/*var buttons=[];
				if(child&&child.length>0){
					$.each(child,function(i,node){
						var temp = {};
						temp.funId=node.id;
						temp.funUrl=BASEPATH+node.link;
						temp.funImg=node.img;
						buttons.push(temp);
						
					});
				}*/
				var url = BASEPATH+treeNode.link;
				if(url.indexOf('?')>=0){
					//url+="&buttons="+urlTool.parseJSON2URL(buttons);
					url+="&pid="+treeNode.id;
				}else{
					//url+="?buttons="+urlTool.parseJSON2URL(buttons);
					url+="?pid="+treeNode.id;
				}
				//url+="&pid="+treeNode.id;
				if(!$("#tabs").tabs("exists",treeNode.name)){
					$('#tabs').tabs('add',{
						id:treeNode.id,
						title: treeNode.name,
						content:"<iframe id='frame"+treeNode.id+"' scrolling='no' frameborder='0'  src='"+url+"' style='width:100%;height:100%;border:none; min-width:780px; min-height:450px;overflow:auto;'></iframe>",
						closable: true,
						able:true
					});
				}else{
					if($('#tabs').tabs('getSelected').panel("options").id==treeNode.id){
						return;
					}
					$('#tabs').tabs('select',treeNode.name);
					//菜单点击是否刷新当前页面
					//exports.exec("refrshSelectTab");
				}
			}else if(treeNode.level==0){ //第一级元素 控制展开关闭
				if(!treeNode.open){
					zTree.expandAll(false);
					zTree.expandNode(treeNode);
				}else{
					zTree.expandNode(treeNode,false);
					return;
				}
			} else { 	//二级及以上 只做展开
				zTree.expandNode(treeNode);
			}
		}else{
			zTree.expandNode(treeNode,true);
			if('moudle'==treeNode.funType){
				var temp = zTree.getNodeByParam("imgSign","imgSign",treeNode.getParentNode());
				if(temp!=null){
					$("#"+temp.tId+"_ico").find("img").attr("src",BASEPATH+temp.img);
					delete temp['imgSign'];
				}
				treeNode.imgSign="imgSign";
				/*var path = treeNode.img.substr(0,treeNode.img.lastIndexOf("/")+1),name=treeNode.img.substr(treeNode.img.lastIndexOf("/")+1);*/
				$(event.target).closest("a").addClass("expand");//.find("img").attr("src",path+"t"+name)
				//$(event.target).closest("a").parent().siblings().each(function(){
					//$(this).children().removeClass("expand");
				//});
			}
			if('menu'==treeNode.funType){
				index++;
				var child =treeNode.children;
				/*var buttons=[];
				if(child&&child.length>0){
					$.each(child,function(i,node){
						var temp = {};
						temp.funId=node.id;
						temp.funUrl=BASEPATH+node.link;
						temp.funImg=node.img;
						buttons.push(temp);
						
					});
				}*/
				var url = BASEPATH+treeNode.link;
				if(url.indexOf('?')>=0){
					//url+="&buttons="+urlTool.parseJSON2URL(buttons);
					url+="&pid="+treeNode.id;
				}else{
					//url+="?buttons="+urlTool.parseJSON2URL(buttons);
					url+="?pid="+treeNode.id;
				}
				//url+="&pid="+treeNode.id;
				if(!$("#tabs").tabs("exists",treeNode.name)){
					$('#tabs').tabs('add',{
						id:treeNode.id,
						title: treeNode.name,
						content:"<iframe id='frame"+treeNode.id+"' scrolling='no' frameborder='0'  src='"+url+"' style='width:100%;height:100%;border:none; min-width:780px; min-height:450px;overflow:auto;'></iframe>",
						closable: true,
						able:true
					});
				}else{
					if($('#tabs').tabs('getSelected').panel("options").id==treeNode.id){
						return;
					}
					$('#tabs').tabs('select',treeNode.name);
					//菜单点击是否刷新当前页面
					//exports.exec("refrshSelectTab");
				}
			}
		}
	}
	var initTabs = function(data){
		$("#tabs").tabs({
			tabHeight:47,
			tools:[{
				iconCls:'icon-all_closed1',
				title:""+Obj.get('base.common.success.Refresh')+"",
				handler:function(){
					var currTab =  $('#tabs').tabs('getSelected'); //获得当前tab
					var id = $(currTab.panel('options').content).attr('id');
				    var url = $(currTab.panel('options').content).attr('src');
				    $('#tabs').tabs('update', {
				      tab : currTab,
				      options : {
				       content :"<iframe id='"+id+"' scrolling='no' frameborder='0'  src='"+url+"' style='width:99.9%;height:99.9%;border:none; '></iframe>"
				      }
				     }); 
				}
			},{
				iconCls:'icon-all_closed',
				//text:"全部关闭",
				/*height:25,*/
				handler:function(){
					var len = $("#tabs").tabs("tabs").length;
					for(var k = 0;k<len;k++){
						$("#tabs").tabs("close",1);
					}
				}
			}]
		});
		var a = $("#tabs").find(".tabs-tool").find("a").css({"padding-top":"8px","margin-left":"5px"});
		var b = $("#tabs").find(".tabs-tool").find("span").css({"line-height":"33px","height":"auto"});
		var c = $("#tabs").find(".tabs-tool").find("table").css({"height":"auto"});
		var d = $("#tabs").find(".tabs-tool").find(".icon-all_closed1").attr({title:""+Obj.get('base.common.success.refresh')+""});
		var e = $("#tabs").find(".tabs-tool").find(".icon-all_closed").attr({title:""+Obj.get('base.common.success.Allclosed')+""});
		var f = $("#tabs").find(".tabs-tool").find(".l-btn-left").css({"padding":"2px 4px"});
		$("#tabs").tabs("add",{
			title:""+Obj.get('base.common.success.home')+"",
			content:"<iframe id='framefront' scrolling='no' frameborder='0'  src='"+BASEPATH+"/view/base/main/front' style='width:100%;height:99.9%;border:none; '></iframe>",
			onload:function(){
				$('#framefront')[0].contentWindow.menudata = $.grep(data,function(a,b){
					return a.funType=="sys"||a.funType=="moudle"||a.funType=="menu";
				});
				$('#framefront')[0].contentWindow.menutree = $.fn.zTree.getZTreeObj("navigat");
			}
		});
	}
	var initNav = function(upfun){
		var treeObj = $("#navigat");
		$("#hide").click(function(){
			$("body").layout("collapse",'west');
		});
		$('#nav-tab').mouseenter(function(){
			if($('.layout-panel-west').css('display')=='block'){
				return;
			}
			$('body').layout('expand','west');
			
		});
	    
//	    退出系统
		$("#logout").on("click",function(){
            using(["messager"],function(){
                $.messager.confirm(""+Obj.get('base.common.success.Systemprompt')+"",""+Obj.get('base.common.success.exitsystem')+"", function(r){
                    if (r){
                        A.init().success(function(code,msg,data){
                            location.href='login';
                        }).error(function(code,msg,data){
                            location.href='login';
                        }).post(BASEPATH+"/base/authoriza/user/logout.htm");
                    }
                });
            });
        });	
		A.init().success(function(code,msg,data){


			var initFunction =function(_i18n){
				if(lang!='zh_CN'){
					if(data&&data.length>0){
						$.each(data,function(i,obj){
							obj.name=_i18n.get(obj.name);
						});
					}
					
				}
				$("#nav-tab").html("");
				data.sort(function(fun1,fun2){
					return fun1.orderBy-fun2.orderBy;
				})
				if(data&&data.length>0){
					var sys=[];
					$.each(data,function(i,obj){
						if(obj.funType=='sys'){
							sys.push(obj);
						}
					});
					if(upfun) upfun(data);
					$.each(sys,function(i,obj){
						var menuId=obj.id;
						$("#nav-tab").append("<li id='"+menuId+"' title='"+obj.name+"' class='menuLevel' oldstyle='"+BASEPATH+obj.img+"' style=\"background: url("+BASEPATH+obj.img+") no-repeat center;\"></li>");
						var arrs = parseRecurrence.getDataByPid({pId:menuId,key:'pId',data:data,id:'id'});
						menuMap[menuId]=arrs;
					});
					$(".menuLevel").click(function(){
						$(this).closest("ul").find("li").each(function(){
							var img = $(this).attr("oldstyle");
							$(this).attr("style","background:url("+img+") no-repeat center")
						});
						var img = $(this).attr("oldstyle").replace('nav_','hover_nav_');
						$(this).attr("style","background:url("+img+") no-repeat center;background-color:#fff");
						var test = $("#navigat").attr("hovers");
						$("#sysname").css({"color":"#4FB6F1"})./*css({"background-image":"url("+img.replace('hover_nav_','mini_nav_')+")"}).*/text($(this).attr("title"));
						var id = $(this).attr("id");
						if(test!=id){
							initTree( menuMap[id],id);
						}else{
							console.log("not need");
						}
					});
					//$(".menuLevel").first().click();
					deptTree(menuMap);
				}
				
			}
			loadI18n("base/func",initFunction);

		}).post(BASEPATH+"/base/authoriza/user/getFunc.htm");
	}
	function initTree(datas,menuId){
		var treeObj=$.fn.zTree.init($("#navigat"), setting, datas);
		 var treeObj = $.fn.zTree.getZTreeObj("navigat");
		 treeObj.expandAll(true);
		 var nodes = treeObj.getNodesByFilter(function(node){
			 if (node.level == 0) {
					if($("#" + node.tId+">ul").find("ul").length==0){
						if(node.pId!="001"){
							if(node.tId=="navigat_1"){
								if(node.orderBy==1){
									$("#"+node.tId+"_span").click();
									tabClick_=false;
								}
							}
						}
						$("#" + node.tId+">a").find("span").last().css({"background":"#ececec"});
						$("#" + node.tId+">a").find("span").last().hover(function(){
							$(this).addClass("spanHover").removeClass("spanHovers");
						},function(){
							$(this).addClass("spanHovers").removeClass("spanHover");
						})
					}else{
						$("#" + node.tId+">a").addClass("expand");
					}
				}
			 var test =node.funType;
			 if(test=='menu'||test=='moudle'||test=='sys'){
				 return false;
			 }
			 return true;
		 });
		 treeObj.hideNodes(nodes);
		 $("#navigat").attr("hovers",menuId);
	}
	
	var massageNOread = function(){
		A.init().success(function(code,msg,data){
			if(code==0){
				//console.log(data);
				if(data.noReadNum!=0){
					$("#massageInfo").html("<div>"+data.noReadNum+"</div>");
				}
			}
		}).post(BASEPATH+"/base/msg/tips/getNoReadNum.htm");
		
//		A.init().success(function(code,msg,data){
//			if(code==0){
//				var waitSignCount = data.waitSignCount;
//				var waitDoneCount = data.waitDoneCount;
//				var count = waitSignCount+waitDoneCount;
//				//console.log(data);
//				if(count!=0){
//					$("#waitmatter").html("<div>"+count+"</div>");
//				}
//			}
//		}).post(BASEPATH+"/act/activitiWaitMatter/queryWaitDoneCount.htm");
	}
	
	function initUser(upfunc){
		massageNOread();
		A.init().success(function(code,msg,data){
			if(typeof upfunc == 'function')
				upfunc(data);
			$("#loginfo").text(data.userName);
			/*if(data.userImg){
				$("#userIcon").attr("src",BASEPATH+data.userImg);
			}*/
			$.each(data.depts,function(i,item){
				if(item.deptId==data.deptId){
					item.selected = true;
					data.deptName = item.deptName;
					return false;
				}
			})
			$("#deptview").html("");
			if(data.depts.length > 1){
				var input = $("<input type='text'>").appendTo($("#deptview")).hide();
				using('combobox',function(){
					input.combobox({
						textField:"deptName",
						valueField:"deptId",
						width:80,
						clearicon:false,
						data:data.depts,
						onSelect:function(recode){
							/*A.init().success(function(code,msg,data){
								location.reload();
							}).post(BASEPATH+'/base/authoriza/login/refresh.htm',{deptId:recode.deptId});*/
						}
					});
					$.data(input[0],"combobox").options.onSelect = function(recode){
						A.init().success(function(code,msg,data){
							location.reload();
						}).post(BASEPATH+'/base/authoriza/login/refresh.htm',{deptId:recode.deptId});
					};
					input.combobox("panel").off("mouseleave");
					input.combobox("panel").on("mouseleave",function(){
						input.combobox("hidePanel");
					});
				})
			}else{
				$("#deptview").append(data.deptName);
			}
		}).post(BASEPATH+"/base/authoriza/user/getCurUser.htm");
	}
	function jumpToPage(obj){
		var dataParam = JSON.parse(obj.attributes.col.value);
		if(dataParam!=null&&dataParam.msgId!=null){
			A.init().success(function(code,msg,data){
				if(code==0){
					if(dataParam.hasOwnProperty("afterOpen")&&dataParam.afterOpen=="open_page"
						&&dataParam.hasOwnProperty("openUrl")&&dataParam.openUrl!=""){
						indexApp.exec("add",{url:BASEPATH+dataParam.openUrl,name:dataParam.msgTypeName});
					}
					$(obj).parent().parent().fadeTo("slow", 0.00001, function(){//fade
						    $(this).slideDown("slow", function() {//slide up
						      $(this).remove();//then remove from the DOM
						      if($("#push_item").children().length==0){
									initMsgTipesHide();
								}
						    });
					  });
					//$(obj).parent().parent().remove();
				}
			}).post(BASEPATH+"/base/msg/tips/readMsgTips.htm",{msgId:dataParam.msgId});
		}
		//indexApp.exec("add",{url:BASEPATH+'/view/act/main/waitmattercode',name:"待办事项"})
	}
	function initMsgTipes(){
		A.init().success(function(code,msg,data){
			//console.log(data);
			if(data!=null&&data.length>0){
				var msg=$("#push_item");
				msg.html("");
				$.each(data,function (i,obj){
					if(i==0){
						maxDate=obj.sendTime;
					}
					var sendTime = new Date(obj.sendTime);
					var mDate = new Date(maxDate);
				    if(sendTime>mDate){
				    	maxDate=obj.sendTime;
				    }
					msg.append("<li>"+"<p>"+obj.msgTitle+"</p>"+"<p><a href='javascript:void(0)' id='"+obj.msgId+"' col = '"+JSON.stringify(obj)+"'>"+obj.msgText+"</a></p>"+"</li>");
					$("#"+obj.msgId).bind("click",function(){
						jumpToPage(this);
					});
				})
				initMsgTipesShow();
			}
		}).post(BASEPATH+"/base/msg/tips/queryMsgTipsByUser.htm",{sendTime:maxDate});
		$("#push_close").click(function(){
			initMsgTipesHide();
		});
	}
	function initMsgTipesHide(){
			$(".push_main").animate({bottom:'-222px'},2000);
	}
	function initMsgTipesShow(){
		$(".push_main").animate({bottom:'0px'},2000);
	}
	var tabClick_=true;
	var deptTree = function(menuMap){
		
		var obj_;
		$("#depttree").ztreebox({
			url:BASEPATH+"/dcs/section/queryProjectTree.htm",
			expandAll:true,
			ztreeopt:{
				view: {
					showLine: true,
					showIcon: false,
					dblClickExpand:false
				},
				data:{
					simpleData:{
						enable: true,
						idKey: "id",
						pIdKey: "pid",
						rootPId: 0
					}
				},
				callback: {
					afterCheck: function(treeobj,data){
						var len = $("#tabs").tabs("tabs").length;
						for(var k = 0;k<len;k++){
							$("#tabs").tabs("close",1);
						}
						if(data[0].level==0){
							obj_.selectNode(data[0]);
							initTree( menuMap[1],1);
						}
						if(data[0].level==2){
							obj_.selectNode(data[0]);
							sessionStorage.setItem('projectId',data[0].id);
							initTree( menuMap["190426144244000037"],"190426144244000037");
						}
						if(data[0].level==3){
							obj_.selectNode(data[0]);
							sessionStorage.setItem('sectionId',data[0].id);
							initTree( menuMap["190426144308000038"],"190426144308000038");
						}
						$(".menuContent").hide();
						if(tabClick_==true){
							var len = $("#tabs").tabs("tabs").length;
							for(var k = 0;k<len;k++){
								$("#tabs").tabs("close",1);
							}
						}
						lengthWidth();
					}
				}
			},
			onLoad:function(obj,event){
				$("#depttree+span").addClass("treebd");
				$("#depttree+span").find("input").first().addClass("bluebd").attr("readonly","readonly");
				$("#depttree+span").find("a").addClass("combo-arrow2");
				$(".menuContent").find(".panel-body.panel-body-noheader").addClass("test-1");
				obj_=obj;
				var nodes = obj.getNodes()[0];
				obj.selectNode(nodes);
				initTree( menuMap[1],1);
				var treeUl = $(".menuContent").find(".panel-body.panel-body-noheader>ul").attr("id");
				$("#"+treeUl+"_1_a").click();
				lengthWidth();
				$(".menuContent").mouseleave(function(){
					$(".menuContent").hide();
				});
				$("#depttree+span").mouseover(function(){
					$(".menuContent").show();
					$("#depttree").click();
				});
				/*$("*").mouseover(function(e){
					if($(this).closest(".menuContent").length!=0||$(this).attr("class")=="ztree"){
						e.stopPropagation(); 
					}else{
						if($(".menuContent").css("display") != "hide"){
							$(".menuContent").hide();
						}
					};
				});*/
			}
		});
	}
	function lengthWidth(){
		var val_length=$("#depttree").val().length*20+20;
		$("#depttree+span").css("width",val_length==0?"150px":val_length+"px");
		$("#depttree+span").find("input").first().addClass("bluebd").css("width",val_length==0?"150px":val_length+"px");
	}
	
	
	
/*	$("*").mouseover(function(e){
		if($(this).closest(".menuContent").length!=0||$(this).attr("class")=="ztree"){
			e.stopPropagation(); 
		}else{
			if($(".menuContent").css("display") != "hide"){
				$(".menuContent").hide();
			}
		};
	});*/
	
	
	module.exports = {
		init: function () {
			using(["datagrid","parser","textbox","messager","dialog","combobox","ztreebox","menu","layout","ztreebase","tabs","ztree_exhide"],function(){
				$("body").layout();
				initNav(initTabs);
				initUser();
				$("#deptview").click(function(){
					if(indexApp) indexApp.exec("refrsh",{link:'/view/dcs/sys/layerAndMaterial/layerAndMaterial',pid:'190326171405000001'});
				})
				$("#loginspan").click(function(){
					indexApp.exec("add",{url:BASEPATH+'/view/base/main/modifyInfo',name:""+Obj.get('base.common.success.information')+Obj.get('base.common.success.modify')+""})
				})
				
				$("#personli").click(function(){
					indexApp.exec("add",""+Obj.get('base.common.success.Personalinformation')+"",BASEPATH+'/view/base/main/personal');
				});
				$("#editpassword").click(function(){
					indexApp.exec("add",{url:BASEPATH+'/view/base/main/personalcode',name:""+Obj.get('base.common.success.Modify')+Obj.get('base.common.success.password')+""})
				});
				$("#waitmatter").click(function(){
					indexApp.exec("add",{url:BASEPATH+'/view/act/main/waitmattercode',name:""+Obj.get('base.common.success.todo')+""})
				});
				$("#communication").click(function(){
					indexApp.exec("add",{url:BASEPATH+'/base/chat/chat.HTML',name:""+Obj.get('base.common.success.im')+""})
				});
				$("#massageInfo").click(function(){
					indexApp.exec("add",{url:BASEPATH+'/view/base/msgPush/msgPush',name:""+Obj.get('base.common.success.msgnotice')+""})
				});
				$("#fresh").click(function(){
					indexApp.exec("refrshSelectTab");
				});
				$("#pushMore").click(function(){
					indexApp.exec("add",{url:BASEPATH+'/view/base/msgPush/msgPush',name:""+Obj.get('base.common.success.msgpush')+""})
				});
				
				/* 加载消息提示*/
//				initMsgTipes();
//				setInterval(initMsgTipes,60000);
			});
		},
		exec:function(){
			if(typeof arguments[0] == "string"){
				return exports.method[arguments[0]].apply($('#tabs')[0],Array.prototype.slice.call(arguments, 1));
			}
		}
	};
	var currentUser;
	exports.method={
		"add":function(arg,arg1){
			if(typeof arg=="string"){
				arg = {name:arg,url:BASEPATH+arg1};
			}
			if(arg.refreshTab){//是否刷新该tab页面/关闭后重新打开
				$("#tabs").tabs("close",arg.name);
			}
			if($("#tabs").tabs("exists",arg.name)){
				$("#tabs").tabs("select",arg.name);
			}else{
				if(arg.id==undefined){
					arg.id = Math.ceil(Math.random()*100);
				}
				if(arg.noframe==true){
					$('#tabs').tabs('add',{
						id:arg.id,
						title: arg.name,
						href:arg.url,
						closable: true,
						onLoad:arg.onLoad
					});
				}else{
					$('#tabs').tabs('add',{
						id:arg.id,
						title: arg.name,
						content:"<iframe id='frame"+arg.id+"' scrolling='no' frameborder='0'  src='"+arg.url+"' style='width:99.9%;height:99.9%;border:none; '></iframe>",
						closable: true
					});
				}
			}
		},
		"close":function(title,arg1){
			if(!title){
				var tab = $('#tabs').tabs('getSelected');
				var index = $('#tabs').tabs('getTabIndex',tab);
				return $('#tabs').tabs('close',index);
			}
			$('#tabs').tabs('close',title);
		},
		"closeSelectTab":function(){
			 var title = $('.tabs-selected').text();  
			 $('#tabs').tabs('close',title);
		},
		"getTab":function(title,arg1){
			return $('#tabs').tabs('getTab',title);
		},
		"logout":function(){
			$("#logout").click();
		},
		"initUser":function(upfunc){initUser(upfunc);},
		"user": function(upfunc){
			if(currentUser&&typeof upfunc=="function")
				upfunc(currentUser);
			else
				A.init().success(function(code,msg,data){
					currentUser = data;
					if(typeof upfunc=="function") upfunc(data);
				}).post(BASEPATH+"/base/authoriza/user/getCurUser.htm");
		},
		"refrshSelectTab":function(){
			var currTab =  $('#tabs').tabs('getSelected'); //获得当前tab
			var id = $(currTab.panel('options').content).attr('id');
		    var url = BASEPATH+$(currTab.panel('options').content).attr('src');
		    $('#tabs').tabs('update', {
		      tab : currTab,
		      options : {
		       content :"<iframe id='"+id+"' scrolling='no' frameborder='0'  src='"+url+"' style='width:99.9%;height:99.9%;border:none; '></iframe>"
		      }
		     }); 
		},
		"refrshTab":function(title){
			if($("#tabs").tabs("exists",title)){
				$("#tabs").tabs("select",title);
				var currTab =  $('#tabs').tabs('getSelected'); //获得当前tab
				var id = $(currTab.panel('options').content).attr('id');
			    var url = $(currTab.panel('options').content).attr('src');
			    $('#tabs').tabs('update', {
			      tab : currTab,
			      options : {
			       content :"<iframe id='"+id+"' scrolling='no' frameborder='0'  src='"+url+"' style='width:99.9%;height:99.9%;border:none; '></iframe>"
			      }
			     }); 
			}
		},
		"refrsh":function(tabs,arg){
			var treeObj = $.fn.zTree.getZTreeObj("navigat");
			var treeNode ;
			if(typeof tabs=="string"){
				treeNode = treeObj.getNodeByParam("link",tabs);
				$("#push_main").show();
			}else{
				treeNode = treeObj.getNodeByParam("link",tabs.link);
			}
			if(treeNode==undefined){
				$("#"+tabs.pid).click();
				treeNode = treeObj.getNodeByParam("link",tabs.link);
			}
			treeObj.selectNode(treeNode,false);
			var child =treeNode.children;
			/*var buttons=[];
			if(child&&child.length>0){
				$.each(child,function(i,node){
					var temp = {};
					temp.funId=node.id;
					temp.funUrl=BASEPATH+node.link;
					buttons.push(temp);
				});
			}*/
			var url = BASEPATH+treeNode.link;
			if(url.indexOf('?')>=0){
				//url+="&buttons="+urlTool.parseJSON2URL(buttons);
				url+="&pid="+treeNode.id;
			}else{
				/*url+="?buttons="+urlTool.parseJSON2URL(buttons);
				if(typeof arg == "object"){
					url+="&arg="+urlTool.parseJSON2URL(arg);
				}*/
				url+="?pid="+treeNode.id;
			}
			//url+="&pid="+treeNode.id;
			var index = -1;
			if($("#tabs").tabs("exists",treeNode.name)){
				index = $("#tabs").tabs("getTabIndex",$("#tabs").tabs("getTab",treeNode.name));
				$("#tabs").tabs("close",index);
			}
			$('#tabs').tabs('add',{
				id:treeNode.id,
				index:index!=-1?index:null,
				title: treeNode.name,
				content:"<iframe id='frame"+treeNode.id+"' scrolling='no' frameborder='0'  src='"+url+"' style='width:99.9%;height:99.9%;border:none; '></iframe>",
				closable: true
			});
		},
		"refrshMessageCount":function(){//刷新消息图标数字
			massageNOread();
		},
		"getButtons":function(pid){
			var treeObj = $.fn.zTree.getZTreeObj("navigat");
			var nodes = treeObj.getNodesByParam("pId",pid);
			for(var i=0;i<nodes.length;i++){
				nodes[i].funId=nodes[i].id;
				nodes[i].funUrl=BASEPATH+nodes[i].link;
			}
			return nodes;
		}
	}
	
});

